package logic

import (
	"context"
	"doctor-medicine-system/models/mysql"
	"errors"

	"doctor-medicine-system/doctorrpc/doctorrpc"
	"doctor-medicine-system/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserShowLogic {
	return &UserShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserShowLogic) UserShow(in *doctorrpc.UserShowRequest) (*doctorrpc.UserShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User

	err := user.UserShowById(mysql.DB, in.UserId)
	if err != nil {
		return nil, errors.New("查询失败")
	}

	return &doctorrpc.UserShowResponse{
		UserId: int64(user.ID),
	}, nil
}
